<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{msg}}
        <div>{{count}}</div>
        <button @click="add">add count</button>

        <child @active="add"></child>
    </div>

    <script src="./js/vue.js"></script>
    <script>

        Vue.component('child',{
            template:`<div class="child">
            <button @click="addparentCount">click</button>
            </div>`,
            methods: {
                addparentCount(){
                    this.$emit("active",3123)
                    console.log('子组件的方法被触发了')
                }
            }
        })
        var app = new Vue({
            el:'#app',
            data:{
                msg:'这是父组件的msg',
                count:0
            },
            methods: {
                add(data){
                    // this.count++
                    this.count = data
                    console.log(data)
                }
            }
        })
    </script>
</body>
</html>